package Test8;

import java.io.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class Demo4 {
    public static void main(String[] args) throws IOException {
        File src=new File("D:\\Test\\《七律·人民解放军占领南京》.txt");
        File des=new File("D:\\Test");
        method(src,des);
    }public static void method(File src,File des) throws IOException {
        ZipOutputStream zos=new ZipOutputStream(new FileOutputStream(new File(des,"七律·人民解放军占领南京》copy.zip")));
        ZipEntry ze=new ZipEntry("七律·人民解放军占领南京》.txt");
        zos.putNextEntry(ze);
        FileInputStream fis=new FileInputStream(src);
        int b;
        while((b= fis.read())!=-1){
            zos.write(b);
        }
        fis.close();
        zos.close();
    }
}
